package com.hzjh.base.log

import com.tencent.mars.xlog.Log

internal class DefaultLoggerImp: ISKLogger {
    override fun v(tag: String, msg: String) {
        android.util.Log.v(tag, msg)
    }

    override fun d(tag: String, msg: String) {
        android.util.Log.d(tag, msg)
    }

    override fun e(tag: String, msg: String, tr: Throwable?) {
        android.util.Log.e(tag, msg, tr)
    }

    override fun i(tag: String, msg: String) {
        android.util.Log.i(tag, msg)
    }

    override fun w(tag: String, msg: String) {
        android.util.Log.w(tag, msg)
    }

    override fun wtf(tag: String, msg: String, tr: Throwable?) {
        if (tr == null) {
            android.util.Log.wtf(tag, msg)
        } else {
            android.util.Log.wtf(tag, tr)
        }

    }

    override fun flushLog() {

    }

}

/**
 * mars log 实现
 */
class MarsLogImp: ISKLogger{
    override fun v(tag: String, msg: String) {
        try {
            Log.v(tag, msg)
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }

    override fun d(tag: String, msg: String) {
        try {
            Log.d(tag, msg)
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }

    override fun e(tag: String, msg: String, tr: Throwable?) {
        try {
            Log.e(tag, msg, tr)
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }

    override fun i(tag: String, msg: String) {
        try {
            Log.i(tag, msg)
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }

    override fun w(tag: String, msg: String) {
        try {
            Log.w(tag, msg)
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }

    override fun wtf(tag: String, msg: String, tr: Throwable?) {
        try {
            Log.e(tag, msg, tr)
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }

    override fun flushLog() {
        Log.appenderFlush()
    }

}